<?php
  
namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Model\Merchant;
use DB;
class SogoController extends Controller
{


    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {

        
        $db = DB::table('merchant')->where("state","0");
        
        $where = [];
        if ($request->has('name')) {
           $name = $request->input("name");
           $db->where("name","like","%{$name}%"); 
           $where['name']=$name;
        }
        
        $sogos = $db->paginate(5); 
        
        //加载模板并放置信息
        return view("admin.sogoIndex",['sogos'=>$sogos,'where'=>$where]);


    }

    
   public function  aa(Request $request)
   {
     
        $db = DB::table('merchant')->where("state","1");
        
        $where = [];
        if ($request->has('name')) {
           $name = $request->input("name");
           $db->where("name","like","%{$name}%"); 
           $where['name']=$name;
        }
        
        $sogos = $db->paginate(5); 
        
        //加载模板并放置信息
        return view("admin.sogoIndex1",['sogos'=>$sogos,'where'=>$where]);

       
   }


   public function  bb(Request $request)
   {
        $db = DB::table('merchant')->where("state","2");
        
        $where = [];
        if ($request->has('name')) {
           $name = $request->input("name");
           $db->where("name","like","%{$name}%"); 
           $where['name']=$name;
        }
        
        $sogos = $db->paginate(5); 
        
        //加载模板并放置信息
        return view("admin.sogoIndex2",['sogos'=>$sogos,'where'=>$where]);



       // $sogos = DB::table('merchant')->where("state","2")->paginate(5);
       // // dd($sogos);
       //  return view('admin.sogoIndex2',['sogos'=>$sogos]);
   }

   
    public function  cc(Request $request)
   {
       
        $db = DB::table('merchant')->where("state","3");
        
        $where = [];
        if ($request->has('name')) {
           $name = $request->input("name");
           $db->where("name","like","%{$name}%"); 
           $where['name']=$name;
        }
        
        $sogos = $db->paginate(5); 
        
        //加载模板并放置信息
        return view("admin.sogoIndex3",['sogos'=>$sogos,'where'=>$where]);

       // $sogos = DB::table('merchant')->where("state","3")->paginate(5);
       // // dd($sogos);
       //  return view('admin.sogoIndex3',['sogos'=>$sogos]);
   }


   public function aa1($id)
    {
        //待审核商家的注册信息详情
        $sogos = DB::table("merchant")->where("id",$id)->where("state","0")->first();
    
        return view("admin.aa",['sogos'=>$sogos]);
    }


    public function bb1($id)
    {
        //待审核商家的注册信息详情
        $sogos = DB::table("merchant")->where("id",$id)->where("state","1")->first();
    
        return view("admin.bb",['sogos'=>$sogos]);
    }


    public function cc1($id)
    {
        //待审核商家的注册信息详情
        $sogos = DB::table("merchant")->where("id",$id)->where("state","2")->first();
    
        return view("admin.cc",['sogos'=>$sogos]);
    }

    public function dd1($id)
    {
        //待审核商家的注册信息详情
        $sogos = DB::table("merchant")->where("id",$id)->where("state","3")->first();
    
        return view("admin.dd",['sogos'=>$sogos]);
    }

    
    public function check($id,$state)
    {
        //修改商家状态  0：未审核 1：审核通过 2审核未通过 3，商家负面信息太多，暂时拉黑
        $res = DB::table('merchant')->where('id',$id)->update(['state'=>$state]);
        if("state=1"){
            return redirect("/shop");
        }else{
            return redirect('/shop1');
        }   

    }


    public function check1($id,$state)
    {
        //修改商家状态  0：未审核 1：审核通过 2审核未通过 3，商家负面信息太多，暂时拉黑
        $res = DB::table('merchant')->where('id',$id)->update(['state'=>$state]);
        if("state=3"){
            return redirect("/shop2");
        }else{
            return redirect('/shop1');
        }   

    }

    public function check2($id,$state)
    {
        //修改商家状态  0：未审核 1：审核通过 2审核未通过 3，商家负面信息太多，暂时拉黑
        $res = DB::table('merchant')->where('id',$id)->update(['state'=>$state]);
        if("state=1"){
            return redirect("/shop");
        }else{
            return redirect('/shop1');
        }   

    }

    public function check3($id,$state)
    {
        //修改商家状态  0：未审核 1：审核通过 2审核未通过 3，商家负面信息太多，暂时拉黑
        $res = DB::table('merchant')->where('id',$id)->update(['state'=>$state]);
        if("state=1"){
            return redirect("/shop");
        }else{
            return redirect('/shop1');
        }   

    }



   

   

  
}
